<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./node_modules/vue/dist/vue.js"></script>

</head>
<body>
    <style>
        .activated{
            color: red;
        }
    </style>
    <div id="app">
        <!-- 数组的class是放的变量的值
            绑定style应该用对象形式
            他俩数组形式其实啥都行
            :style="[isActivated]"(一样的)
        -->
        <h1 @click="handleDivClick()"
             :style="isActivated"  
             :class="[activated,anotherActivated]"
        >你要是点我我就咔咔变色</h1>
    </div>

    <script>
    var vm = new Vue({
        el:"#app",
        data:{
            isActivated:{
                color:'#000000'
            },
            isTrue:true,
            anotherActivated:'abc',
            activated:'bbc'
        },
        methods:{
            handleDivClick(){
                this.isTrue=!this.isTrue
                _that = this
                setInterval(function(){
                     _that.isActivated.color= _that.createHexRandom()
                }
                   ,100
                )
                
            },
            createHexRandom(){  
                var num = '#';
            for (i = 0; i <= 5; i++)
            {
                var tmp = Math.ceil(Math.random()*15); 
                if(tmp > 9){
           switch(tmp){  
               case(10):
                   num+='a';
                   break; 
               case(11):
                   num+='b';
                   break;
               case(12):
                   num+='c';
                   break;
               case(13):
                   num+='d';
                   break;
               case(14):
                   num+='e';
                   break;
               case(15):
                   num+='f';
                   break;
           } 
        }else{
           num+=tmp;
        }
 }
//  alert(num)
 return num;
}
        }
    })
        
        
    </script>
</body>
</html>